package com.api.shopapi.mapper;

import com.api.shopapi.entity.NurseStaffRel;
import com.api.shopapi.entity.dto.NurseStaffRelDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface NurseStaffRelMapper {

    @Insert("insert into nurse_staff_rel " +
            "(NurseStaffRelCode,NurseCode,StaffCode) " +
            "values (#{nurseStaffRel.NurseStaffRelCode} ,#{nurseStaffRel.NurseCode} ,#{nurseStaffRel.StaffCode} )")
    int insert(@Param("nurseStaffRel") NurseStaffRel nurseStaffRel);

    @Delete("delete from nurse_staff_rel where nurseCode=#{nurseCode} and StaffCode=#{nurseStaffCode}")
    int delByNurseCodeAndNurseStaffCode(@Param("nurseCode") String nurseCode, @Param("nurseStaffCode") String nurseStaffCode);

    @Select("select * from nurse_staff_rel where NurseCode=#{nurseCode} and StaffCode=#{nurseStaffCode} limit 1")
    NurseStaffRel getByNurseCodeAndNurseStaffCode(@Param("nurseCode") String nurseCode, @Param("nurseStaffCode") String nurseStaffCode);

    @Select("select * from nurse_staff_rel where nurseCode=#{nurseCode}")
    List<NurseStaffRelDTO> getListByNurseCode(@Param("nurseCode") String nurseCode);

    @Select("select * from nurse_staff_rel where StaffCode=#{nurseStaffCode} limit 1")
    NurseStaffRel getByNurseStaffCode(@Param("nurseStaffCode") String nurseStaffCode);


    @Delete("delete from nurse_staff_rel where nurseStaffRelCode=#{nurseStaffRelCode}")
    int delete(@Param("nurseStaffRelCode") String nurseStaffRelCode);


}
